var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var a in t) t.hasOwnProperty(a) && (e[a] = t[a]);
    })(e, t);
}, function(e, t) {
    function a() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (a.prototype = t.prototype, 
    new a());
}), a = this && this.__decorate || function(e, t, a, n) {
    var i, o = arguments.length, r = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, a) : n;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, a, n); else for (var s = e.length - 1; 0 <= s; s--) (i = e[s]) && (r = (o < 3 ? i(r) : 3 < o ? i(t, a, r) : i(t, a)) || r);
    return 3 < o && r && Object.defineProperty(t, a, r), r;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("LevelView"), s = e("HeadView"), c = e("PersonView"), l = e("AudioManager"), d = e("Global"), u = e("RecorderManager"), p = e("PrefabView"), h = e("PetManager"), f = e("GameConfig"), g = e("GameData"), m = e("DataManager"), y = e("WebManager"), v = e("LoadManager"), w = e("UIManager"), b = cc._decorator, P = b.ccclass, I = b.property, G = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.levelView = null, e.headView = null, e.personView = null, e.sprite = null, 
        e.infoLabel = null, e.nameLabel = null, e.nextBtn = null, e.data = [], e.isRecorder = !1, 
        e;
    }
    return i(e, t), e.prototype.onClickRecorder = function() {
        var t = this;
        l.default.getInstance().playAudio("按钮2"), y.default.getInstance().sentLog("TryShareVideo"), 
        GA.isByteDance() && !this.isRecorder && (this.isRecorder = !0, cc.game.pause(), 
        GA.PA.shareAppMessage({
            channel: "video",
            title: "我就要吃鸡",
            desc: "进入吃鸡的世界",
            imageUrl: "",
            templateId: "3eld33adx4d3bk46j6",
            query: "krq_wjycj=10002",
            extra: {
                videoPath: u.default.getInstance().videoPath,
                videoTopics: [ "我就要吃鸡", "卡日曲游戏" ],
                withVideoId: !0,
                createChallenge: !1
            },
            success: function(e) {
                cc.game.resume(), y.default.getInstance().sentLog("ShareVideoSuccess"), t.isRecorder = !1, 
                e.videoId && y.default.getInstance().saveVideoId({
                    aliasId: e.videoId,
                    success: function(e) {
                        console.log("保存视频成功:", e);
                    }
                }), console.log("分享视频成功:", e), t.doReward(), t.doNext();
            },
            fail: function(e) {
                cc.game.resume(), y.default.getInstance().sentLog("ShareVideoFailed"), t.isRecorder = !1, 
                "shareAppMessage:cancel" == e.errMsg || "shareAppMessage:fail video duration is too short" == e.errMsg && w.default.getInstance().showToast({
                    str: "抱歉,录屏时间太短！"
                }), console.log("分享视频失败:", e);
            }
        }));
    }, e.prototype.onClickNext = function() {
        l.default.getInstance().playAudio("按钮2"), y.default.getInstance().sentLog("点击结算2界面录屏取消按键"), 
        g.GD.recorderCount++, this.doNext();
    }, e.prototype.doReward = function() {
        0 < this.data.length && (this.data.forEach(function(e) {
            switch (e.type) {
              case d.RewardType.DIAMOND:
                g.GD.updateNumber("diamond", e.num);
                break;

              case d.RewardType.SKIN:
                g.GD.addSkin(e.idx) && m.default.getInstance().upload({
                    json: !0,
                    local: !0,
                    skin: e.idx
                }), g.GD.personIdx < e.idx && (g.GD.personIdx = e.idx);
                break;

              case d.RewardType.PET:
                h.default.getInstance().isHas(0) || (h.default.getInstance().getRealData(0).has = 1);
                break;

              case d.RewardType.PIECE:
                g.GD.updateNumber("diamond", e.num);
            }
        }), m.default.getInstance().save(), w.default.getInstance().loadPopPnl("reward", this.data[0]));
    }, e.prototype.doNext = function() {
        w.default.getInstance().hideAllPnl(), w.default.getInstance().showPnl("start");
    }, e.prototype.start = function() {
        var e = this;
        this.levelView.refresh(g.GD.level), this.headView.init(g.GD.playerData.icon, g.GD.playerData.nickname, g.GD.personIdx);
        var t = 100 * (50 + 4 * d.G.getRank(g.GD.level).r);
        this.infoLabel.string = "已超越" + (GA.rand(t, 400 + t) / 100).toFixed(2) + "%的玩家", 
        this.scheduleOnce(function() {
            e.nextBtn.node.active = !0;
        }, f.GC.recorderDelayTime);
    }, e.prototype.init = function(e) {
        if (this.data = e, 0 < this.data.length) switch (this.data[0].type) {
          case d.RewardType.DIAMOND:
            this.sprite.node.active = !0, v.default.getInstance().loadSpriteFrame({
                url: "image/ui/钻石奖励",
                sprite: this.sprite
            }), this.nameLabel.string = "钻石 x " + this.data[0].num;
            break;

          case d.RewardType.SKIN:
            this.personView.node.active = !0, this.personView.init(this.data[0].idx), this.nameLabel.string = d.G.getPersonModel(this.data[0].idx).m;
            break;

          case d.RewardType.PET:
            this.personView.node.active = !0, this.personView.initPet(this.data[0].idx), this.nameLabel.string = "机械狗";
            break;

          case d.RewardType.PIECE:
            this.sprite.node.active = !0, v.default.getInstance().loadSpriteFrame({
                url: "image/ui/碎片@2x",
                sprite: this.sprite
            }), this.nameLabel.string = "碎片 x " + this.data[0].num;
        }
    }, a([ I(r.default) ], e.prototype, "levelView", void 0), a([ I(s.default) ], e.prototype, "headView", void 0), 
    a([ I(c.default) ], e.prototype, "personView", void 0), a([ I(cc.Sprite) ], e.prototype, "sprite", void 0), 
    a([ I(cc.Label) ], e.prototype, "infoLabel", void 0), a([ I(cc.Label) ], e.prototype, "nameLabel", void 0), 
    a([ I(cc.Button) ], e.prototype, "nextBtn", void 0), a([ P ], e);
}(p.default);

n.default = G;